import java.util.HashSet;
import java.util.Set;

public class Demo {
    public static void main(String[] args) {
        int[] nums = {1,2,3,4};
        System.out.println(containsDuplicate(nums));
    }
    public static boolean containsDuplicate(int[] nums) {
        Set<Integer> set  = new HashSet<>();
        boolean ret  = false;
        for (int i = 0; i < nums.length; i++) {
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else {
                ret = true;
                return ret;
            }
        }
       return ret;
    }
}
